
<%@page import="java.util.Date"%>

<%@page import="java.io.FileOutputStream"%>
<%@page import="java.io.InputStream"%>
<%@page import="org.apache.commons.fileupload.FileItem"%>
<%@page import="java.util.List"%>
<%@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@page import="java.io.File"%>
<%@page import="com.lmpop.frame.util.Config" %>
<%@page contentType="text/html; charset=utf-8" %>
<%@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%
	request.setCharacterEncoding("UTF-8");
	Config configFile = new Config();
	configFile.init();
	String rootpath = configFile.getString("rootpath");
	String tempDir =rootpath+"templets/html/www/images";
	String skip_type = "r";
	DiskFileItemFactory factory = new DiskFileItemFactory();
	factory.setSizeThreshold(1024*1024);//设置上传文件大小 
	factory.setRepository(new File(tempDir));//设置上传文件保存的临时目录
	ServletFileUpload upload = new ServletFileUpload(factory); 

	List ls = upload.parseRequest(request);
	for(int i=0;i<ls.size();i++){
	FileItem item = (FileItem)ls.get(i);
	if(item.isFormField()){
		if(!item.getFieldName().toLowerCase().equals("submit")){
			System.out.println(item.getString());
		}
	}else{
		//处理文件域信息
		//将信息取出到程序中
		int start = item.getName().lastIndexOf(".");
		String fileName = item.getName().substring(start);
		InputStream is = item.getInputStream();
		byte[] buffer = new byte[500];
		
		//存储到本地文件中
		FileOutputStream fos = new FileOutputStream(tempDir+"/"+"logo"+".jpg");
		
		while(is.read(buffer)>0){
			fos.write(buffer);
		}
		
		fos.close();
		is.close();
	}
}

	
%>
<script charset="utf-8">
var skip_type = "<%=skip_type%>";
		if(skip_type == "r"){
		alert('LOGO更新成功，现在需要到"网站更新"中更新网站信息！');
		window.location.href='index.jsp';	
		
		}	
</script>